package net.dgg.dggcloud.service.jrcrm.service.log;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import net.dgg.dggcloud.service.common.base.service.BaseService;
import net.dgg.dggcloud.service.entity.user.User;
import net.dgg.dggcloud.service.jrcrm.dao.log.SysSeePhoneRecordDao;
import net.dgg.dggcloud.service.jrcrm.entity.log.SysSeePhoneRecord;
import net.dgg.dggcloud.service.jrcrm.utils.IpUtil;

/**
 * 查看号码日志Service
 * 
 * @Title: SysSeePhoneRecordService
 * @Description:
 * @Auther: 雷力
 * @Date: 2018-11-26 10:58:08
 *
 */
@Service
public class SysSeePhoneRecordService extends BaseService implements SysRecordService {

	@Autowired
	private SysSeePhoneRecordDao dao;

	/**
	 * 插入数据(Map)
	 * 
	 * @param map
	 */
	@Override
	public void insert(Map<String, Object> map) {
		logger.error("=====>"+SysSeePhoneRecordService.class+"=====>插入数据...");
		dao.insert(map);
	}

	/**
	 * 插入数据
	 * 
	 * @param user    操作人
	 * @param no      商机编号
	 * @param request
	 */
	public void insert(User user, String no, HttpServletRequest request) {
		SysSeePhoneRecord record = new SysSeePhoneRecord();
		record.setBusinessNo(no);
		record.setId(keyWorker.nextId());
		record.setIp(IpUtil.getIPAddress(request));
		record.setOpreateTime(new Date());
		record.setUserLoginname(user.getLoginName());
		record.setUserName(user.getName());

		dao.saveByHiber(record);
	}

	/**
	 * 根据map查询集合
	 * 
	 * @param map
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	public List<Map> listSeePhoneRecordByMap(Map<String, Object> map) {
		return dao.listSeePhoneRecordByMap(map);
	}

	/**
	 * 根据map查询行数
	 * 
	 * @param map
	 * @return
	 */
	public Integer countSeePhoneRecordByMap(Map<String, Object> map) {
		return dao.countSeePhoneRecordByMap(map);
	}

}
